package com.zx.controller.user;

import com.zx.dto.request.user.ReceivingDtoRequest;
import com.zx.dto.response.user.ReceivingDtoResult;
import com.zx.service.user.ReceivingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author sunkai
 * @date 2022/8/17 0017 17:08
 * @mood zhou xun
 */
@Controller
@RequestMapping("/receiving")
public class ReceivingController {
    @Autowired
    private ReceivingService receivingService;
    @GetMapping("/address/list")
    @ResponseBody
    public List<ReceivingDtoResult> queryAddress(ReceivingDtoRequest receivingDtoResult, @CookieValue("UserToken") String userToken){
        return receivingService.queryAddress(userToken,receivingDtoResult);
    }
    @PostMapping("/add/address")
    @ResponseBody
    public boolean addAddress(ReceivingDtoRequest receivingDtoResult){
        return receivingService.addAddress(receivingDtoResult);

    }
    @PostMapping("/update/address")
    @ResponseBody
    public boolean updateAddress(ReceivingDtoRequest receivingDtoResult, @CookieValue("UserToken") String userToken){
        return receivingService.updateAddress(userToken, receivingDtoResult);
    }
    @PostMapping("/delete/address")
    @ResponseBody
    public boolean deleteAddress(ReceivingDtoRequest receivingDtoResult){
        return  receivingService.deleteAddress(receivingDtoResult);
    }
}
